const electron = window.require("electron");
const fs = window.require("fs");
const path = window.require("path");
const request = window.require("request");

const watchModeType = {
  list: "LIST",
  grid: "GRID"
};

const __remote = electron.remote;
const ipcRenderer = electron.ipcRenderer;
const dialog = __remote.dialog;
const ipcMain = __remote.ipcMain;
const homePath = __remote.app.getPath("home");
const clipboard = __remote.clipboard;
const DOWNLOAD_PATH = path.join(homePath + "/pineappleNetdisk");
const notification = function(text) {
  new window.Notification("凤梨网盘", {
    title: "凤梨网盘",
    body: text
  });
};

const newWindow = function(url) {
  let win = new __remote.BrowserWindow({
    width: 800,
    height: 600,
    webPreferences: {
      nodeIntegration: true,
      enableRemoteModule: true
    }
  });
  win.loadURL(url).then(null);
  return win;
};

const config = {
  chunkSize: 5242880,
  baseURL: "http://localhost:8033"
};

export {
  __remote,
  watchModeType,
  newWindow,
  ipcRenderer,
  ipcMain,
  dialog,
  fs,
  config,
  notification,
  DOWNLOAD_PATH,
  path,
  request,
  clipboard
};
